#ifndef FILEINFOR_H
#define FILEINFOR_H

#include <QObject>
#include <mutex>
#include <QQueue>
#include <QPair>
#include "mytypes.h"
class FileInfor final:public QObject
{
    Q_OBJECT
public:
    static FileInfor* GetInstance(QObject* parent=nullptr);
    virtual ~FileInfor();

    static const QStringList WarningString;

    enum JudgeState{Normal=0,Doubt,Illegal};//正常,怀疑，不合法

    void SubmitInfor(Yzty::ITEMCODE mcode,QVector<Yzty::BaceInfor*>& infors);

    const QVector<Yzty::BaceInfor*>& GetItemInfor(Yzty::ITEMCODE);

    void AddFileCheckRecord(Yzty::FileCheckRecord* infors);             //设置信息

    void SetFileCheckCondition(const Yzty::FileCheckCondition& condtion);

    void SetNewFileInfor(const Yzty::FileLevelPerson infor, int indexi, int indexj); //后续设置判定人等信息

    int GetTotalKeyWords();

    void SwapClassfity(Yzty::MODECODE scode,int index,Yzty::MODECODE pcode);

    void Clear();           //清空保存信息
    QVector<Yzty::BaceInfor*>& GetFileReportinfor(); //返回未分类的文件检查信息

    QVector<Yzty::BaceInfor*>& GetModifiableInfor(Yzty::ITEMCODE);
 //   void UpdateInfor(QVector<Yzty::BaceInfor*> infors);
    void AddByperson(int i,Yzty::BaceInfor* infor);
    void removeByPerson(int i,Yzty::BaceInfor* infor);
 //   QVector<int> GetFilecnts();
    void Resetcnts();
    int GetFilecnts();
    int GetCheckcnts();
    int GetHitcnts();
    void SetFilecnts(int cnts);
private:
    explicit FileInfor(QObject* parent=nullptr);
    static FileInfor* _instance;

    void ClassifityInfor(Yzty::FileCheckRecord* record);         //信息格式化划分消息
    void Initcnts();
    bool File_Secret_Flag(QString);

private:
    std::mutex _mutex;
    QVector<Yzty::FileCheckRecord*>                           _allinfors; //所有信息

    Yzty::FileCheckCondition        _codition;              //搜索条件
    int         _totals;                                    //当前搜索所包含的关键词总数

    QVector<QVector<Yzty::BaceInfor*>>                      _infors;
    QVector<Yzty::BaceInfor*>                               _fileinfor;     //未被分类的文件检查信息，用于报告输出
//    QVector<int>                               _filecnts;       // 统计文件数{"扫描文件数:","检查文件数:","命中文件数:"}
    std::atomic<int>                             _hitcnts;
    std::atomic<int>                             _checkcnts;
    std::atomic<int>                             _filecnts;

};

#endif // FILEINFOR_H
